<template>
  <div class="cuxiao-container" :class="{'payment-style':isPayment}">
    <div class="container" v-if="cuxiaoData.ecCoupons" @click.self="closeThis">
      <h4 @click="closeThis">{{cuxiaoData.name}}</h4>
      <div class="cuxiao-body" ref="cuxiaoBody">
        <div class="cuxiao-main">
          <h5>促销详情</h5>
          <ul class="cuxiao-lists">
            <li v-for="(item,index) in cuxiaoData.ecCoupons" :key="index">
              <div class="cuxiao-main-top flex-box">
                <div class="list-left flex-box">
                  <p>{{item.name}}</p>
                </div>
                <button @click="selectCuXiao(item.id)">选取</button>
              </div>
              <h6>活动时间：</h6>
            </li>
          </ul>
        </div>
        <div class="bottom-btn">
          <button @click="selectCuXiao('0')">不使用促销</button>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
// @ is an alias to /src

export default {
  data() {
    return {
      list: ''
    }
  },
  props: ['showCuXiao', 'cuxiaoData', 'isPayment'],
  methods: {
    closeThis() {
      this.$bus.$emit('closeChuXiao', false)
    },
    selectCuXiao(id) {
      this.cuxiaoData.couponId = id
      if (this.isPayment) {
        this.$bus.$emit('selectPaymentId', this.cuxiaoData)
      } else {
        this.$bus.$emit('selectChuXiaoId', this.cuxiaoData)
      }
    }
  },
  created() {},
  mounted() {}
}
</script>
<style lang="scss" scoped>
.cuxiao-container {
  width: 100%;
  position: fixed;
  top: 48px;
  bottom: 0;
  left: 0;
  z-index: 9;
  background: rgba($color: #f0f0f0, $alpha: 0.9);
  &.payment-style {
    top: 0;
  }
  .container {
    max-width: 750px;
    height: 100%;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;
    background: url('../../assets/img/cuxiao-bg.png') top no-repeat;
    background-size: 100%;
    .cuxiao-body {
      width: 100%;
    }
    h4 {
      font-size: 16px;
      line-height: 20px;
      padding: 20px 0;
      color: #fff;
    }
    .cuxiao-main {
      width: 100%;
      padding: 18px 10px;
      box-sizing: border-box;
      border-radius: 8px;
      background: #fff;
      text-align: left;
      overflow: hidden;
      h5 {
        font-size: 16px;
        line-height: 20px;
        margin-bottom: 4px;
        color: #333;
      }
      .cuxiao-lists {
        width: 100%;
        float: left;
        li {
          width: 100%;
          float: left;
          justify-content: space-between;
          -webkit-justify-content: space-between;
          border-bottom: 1px dashed #eee;
          padding-bottom: 12px;
          padding-top: 12px;
          &:last-child {
            border-bottom: 0;
          }
          .list-left {
            width: 100%;
            min-height: 48px;
            padding: 0 10px;
            box-sizing: border-box;
            background: rgb(255, 92, 92);
            // border: 1px solid #eee;
          }
          p {
            width: 100%;
            font-size: 14px;
            color: #fff;
          }
          button {
            width: 80px;
            height: 48px;
            color: #fff;
            font-size: 16px;
            font-weight: bold;
            border: 1px solid rgb(255, 92, 92);
            outline: none;
            background: #fff;
            color: rgb(255, 92, 92);
          }
        }
        h6 {
          font-size: 14px;
          margin-top: 12px;
          color: #aaa;
          line-height: 18px;
        }
      }
    }
  }
  .bottom-btn {
    width: 100%;
    margin-top: 12px;
    button {
      background: #bbb;
      color: #fff;
      font-size: 16px;
      width: 100%;
      border-radius: 2px;
      border: none;
      height: 40px;
    }
  }
}
</style>
